{% extends 'core.html' %}

{% load ahmia_tags %}
{% load i18n %}
{% load static %}

{% block title %}
  {% blocktrans %}
    Search results for {{ query_string }}
  {% endblocktrans %} &mdash; Ahmia
{% endblock %}

{% block body %}
  <div id="ahmiaResultsPage">

    <div id="resultsFiltersMenuWrapper">
      <ul id="resultsFiltersMenu">
        <li class="category">
          <a href="#" class="label">
            Any Time<img src="{% static 'images/ddarrow.png' %}">
          </a>
          <ul class="options">
            <li class="first child">
              <a href="{% add_query_params request d='all' %}">Any Time</a>
            </li>
            <li class="child">
              <a href="{% add_query_params request d=1 %}">Last Day</a>
            </li>
            <li class="child">
              <a href="{% add_query_params request d=7 %}">Last Week</a>
            </li>
            <li class="last child">
              <a href="{% add_query_params request d=30 %}">Last Month</a>
            </li>
          </ul>
        </li>
      </ul>
    </div>

    {% if suggest != None %}
      <div id="didYouMean">
        <p> {% trans "Did you mean" %}
          <a href="{% add_query_params request q=suggest %}">
            <i>{{ suggest }}</i>
          </a>?
        </p>
      </div>
    {% endif %}

    {% if total_search_results == 0 %}
      <p id="noResults">
        {% blocktrans %}
          Sorry, but Ahmia couldn't find results for
          <code>{{ query_string }}</code>.<br>
          Please try a different search or try again later.
        {% endblocktrans %}
      </p>

    {% else %}
      <div class="resultsSubheader">
        <p>
          {% blocktrans %}
            Omitted very similar entries. Displaying
            <span class="resultNumber" id="totalResults">
              {{ total_search_results }}
            </span>
            matches in
            <span class="resultNumber" id="searchTime">
              {{ search_time }}
            </span> seconds. Page
            <span class="resultNumber" id="pageResultBegin">
              {{ page }}
            </span>
            of
            <span class="resultNumber" id="pageResultEnd">
              {{ max_pages }}
            </span>.
          {% endblocktrans %}
        </p>
      </div>

      <ol class="searchResults">
        {% for result in search_results %}
          {% if result.type == "questionnaire" %}
          <li class="result" style="background: #E0FFFF">
          {% elif result.type == "help" %}
          <li class="result" style="background: #98FB98">
          {% elif result.type == "nohelp" %}
          <li class="result" style="background: #FFF8DC">
          {% else %}
          <li class="result">
          {% endif %}
            <h4>
              <a
                href="{% url 'search:onion-redirect' %}?search_term={{ query_string }}&redirect_url={{ result.url }}">
                {% if result.title %}
                  {{ result.title | escape }}
                {% elif result.anchors %}
                  {{ result.anchors | escape }}
                {% endif %}
              </a>
              {% if result.url_tor2web %}
                -- <a href="{{ result.url_tor2web }}">Proxy</a>
              {% endif %}
            </h4>
            {% if result.meta %}
              <p>{{ result.meta | escape | truncatechars:300 }}</p>
            {% else %}
              <p>{% trans "No description provided" %}</p>
            {% endif %}
            <cite>{{ result.domain }}</cite>
            {% if result.updated_on %}
            &mdash;
            <span class="lastSeen" data-timestamp="{{ result.updated_on }}">
                  {{ result.updated_on|timesince:now }} {% trans "ago" %}
            </span> &mdash;
            {% endif %}
            <!--
            <span class="abuseReportForm">
              {# todo invalid url #}
              <a href="/blacklist/report?onion={{ result.domain|urlencode }}"
                 data-href="{{ result.domain }}"
                 title="{% trans 'Report this link to us' %}"
                 class="reportAbuse">
                {% trans "Report Abuse" %}
              </a>
              <span class="abuseReportReceived hidden">
                {% trans "Abuse report sent." %}
              </span>
              <span class="abuseReportError hidden">
                {% trans "Abuse report error." %}
              </span>
            </span>
            -->
          </li>
        {% endfor %}
      </ol>
    {% endif %}

  </div>
{% endblock %}
{% block extra_js %}
  <script src="{% static 'results.js' %}"></script>
{% endblock %}
